package me.zhengjie.spider.common;

import lombok.Getter;

@Getter
public enum WebTypeEnum {

    VIDEO("视频", "video_code"),
    CARICATURE("视频", "caricature_code");


    private final String name;
    private final String type;

    WebTypeEnum(String name, String type) {
        this.name = name;
        this.type = type;
    }

    public static WebTypeEnum getByName(String name) {
        for (WebTypeEnum webTypeEnum : WebTypeEnum.values()) {
            if (webTypeEnum.getName().equals(name)) {
                return webTypeEnum;
            }
        }
        return null;
    }

    public static WebTypeEnum getByType(String type) {
        for (WebTypeEnum webTypeEnum : WebTypeEnum.values()) {
            if (webTypeEnum.getType().equals(type)) {
                return webTypeEnum;
            }
        }
        return null;
    }

    public static boolean hasWeb(String type) {
        for (WebTypeEnum webTypeEnum : WebTypeEnum.values()) {
            if (webTypeEnum.getType().equals(type)) {
                return true;
            }
        }
        return false;
    }
}
